//
//  TabBarController.m
//  shopTest
//
//  Created by 梁佳佳 on 2016/11/14.
//  Copyright © 2016年 梁佳佳. All rights reserved.
//

#import "LJJTabBarController.h"
#import "LJJNavigationController.h"

@interface LJJTabBarController ()

@property (strong, nonatomic) NSMutableArray *viewControllersArray;
@property (strong, nonatomic) NSArray *itemImagesArray;
@property (strong, nonatomic) NSArray *itemNamesArray;

@end

@implementation LJJTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:56/255.0 green:165/255.0 blue:241/255.0 alpha:1]} forState:(UIControlStateSelected)];
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:132/255.0 green:132/255.0 blue:132/255.0 alpha:1]} forState:(UIControlStateNormal)];
    [self configViewController];//添加视图
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

#pragma mark -
#pragma mark - method
- (void)configViewController
{
    for (int i = 0; i < self.itemNamesArray.count; i ++) {
        NSString *vcName = self.viewControllersArray[i];
        UIViewController *vc = [[NSClassFromString(vcName) alloc] init];
        vc.tabBarItem.image = [UIImage imageNamed:self.itemImagesArray[i]];
        vc.tabBarItem.selectedImage = [UIImage imageNamed:self.itemImagesArray[i + self.itemNamesArray.count]];
        vc.title = self.itemNamesArray[i];
        LJJNavigationController *nav = [[LJJNavigationController alloc] initWithRootViewController:vc];
        [self.viewControllersArray replaceObjectAtIndex:i withObject:nav];
    }
    self.viewControllers = self.viewControllersArray;
}
#pragma mark -
#pragma mark - lazy method
- (NSMutableArray *)viewControllersArray
{
    if (!_viewControllersArray) {
        _viewControllersArray = [NSMutableArray arrayWithArray:@[@"LJJTimeViewController", @"LJJClassViewController", @"LJJBuyCarViewController", @"LJJMyViewController"]];
    }
    return _viewControllersArray;
}
- (NSArray *)itemImagesArray
{
    if (!_itemImagesArray) {
        _itemImagesArray = @[@"菜单栏限时特卖按钮未选中状态", @"菜单栏分类按钮未选中状态", @"菜单栏购物车按钮未选中状态", @"菜单栏我的按钮未选中状态", @"菜单栏限时特卖按钮选中状态", @"菜单栏分类按钮选中状态", @"菜单栏购物车按钮选中状态", @"菜单栏我的按钮选中状态"];
    }
    return _itemImagesArray;
}
- (NSArray *)itemNamesArray
{
    if (!_itemNamesArray) {
        _itemNamesArray = @[@"限时购", @"分类", @"购物车", @"我的"];
    }
    return _itemNamesArray;
}
@end
